Crate memmapix

source ·
Expand description

A pure Rust cross-platform Rust API for memory mapped buffers.

The core functionality is provided by either Mmap or MmapMut, which correspond to mapping a File to a &[u8] or &mut [u8] respectively. Both function by dereferencing to a slice, allowing the Mmap/MmapMut to be used in the same way you would the equivalent slice types.

Examples

For simple cases Mmap can be used directly:

use std::fs::File;
use std::io::Read;

use memmapix::Mmap;

let mut file = File::open("LICENSE-APACHE")?;

let mut contents = Vec::new();
file.read_to_end(&mut contents)?;

let mmap = unsafe { Mmap::map(&file)?  };

assert_eq!(&contents[..], &mmap[..]);

However for cases which require configuration of the mapping, then you can use MmapOptions in order to further configure a mapping before you create it.

Structs

  • A handle to an immutable memory mapped buffer.
  • A handle to a mutable memory mapped buffer.
  • A memory map builder, providing advanced options and flags for specifying memory map behavior.
  • A handle to a raw memory mapped buffer.
  • MREMAP_* flags for use with mremap.

Enums

Traits